//
//  ShareOpemListTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/6/14.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ShareOpemListTableViewCell.h"

@interface ShareOpemListTableViewCell ()
/**  图片   */
@property (strong, nonatomic) UIImageView  *actImageView;
/**  标题  */
@property (strong, nonatomic) UILabel  *actLabel;
/**  时间  */
@property (strong, nonatomic) UILabel  *timeLabel;
/**  张数  */
@property (strong, nonatomic) UILabel  *actNumberLabel;
/**  积分  */
@property (strong, nonatomic) UILabel  *addressLabel;

/**  图片上面的类型  */
@property (strong, nonatomic) UILabel  *statusLabel;

@end
@implementation ShareOpemListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

/**  120  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
        
        
        TenGrayShadowView *under = [TenGrayShadowView new];
        under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under];
        under.sd_layout.bottomEqualToView(self).heightIs(10 * [UIScreen zj_screenHScale]).widthIs([UIScreen zj_screenWith]).leftEqualToView(self);
    }
    return self;
}





#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.actImageView];
    [self addSubview:self.addressLabel];
    [self addSubview:self.statusLabel];
    [self addSubview:self.actLabel];
    [self addSubview:self.timeLabel];
    [self addSubview:self.actNumberLabel];
   
    
    self.actImageView.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self,12 * [UIScreen zj_screenWScale])
    .heightIs(90 * [UIScreen zj_screenHScale])
    .widthIs(130 * [UIScreen zj_screenWScale]);
    
    
    self.addressLabel.sd_layout
    .bottomEqualToView(self.actImageView)
    .leftSpaceToView(self.actImageView,10 * [UIScreen zj_screenWScale])
    .heightIs(13 * [UIScreen zj_screenHScale])
    .widthIs(150 * [UIScreen zj_screenWScale]);
    
    
    self.actLabel.sd_layout
    .topEqualToView(self.actImageView)
    .leftEqualToView(self.addressLabel)
    .heightIs(13 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 200 * [UIScreen zj_screenWScale]);
    
    self.actNumberLabel.sd_layout
    .topEqualToView(self.actImageView)
    .rightSpaceToView(self, 10 * [UIScreen zj_screenWScale])
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs(60 * [UIScreen zj_screenWScale]);
    
    self.timeLabel.sd_layout
    .topSpaceToView(self.actLabel,8 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.addressLabel)
    .heightIs(12 * [UIScreen zj_screenHScale])
    .widthIs([UIScreen zj_screenWith] - 180 * [UIScreen zj_screenWScale]);

    
    self.statusLabel.sd_layout
    .topEqualToView(self.actImageView)
    .leftEqualToView(self.actImageView)
    .heightIs(30 * [UIScreen zj_screenHScale])
    .widthIs(25 * [UIScreen zj_screenWScale]);
    
    
    
    
}


#pragma mark - 私有方法
- (void)setModel:(ShareOpenListModel *)model{
    _model = model;
     self.actImageView.backgroundColor = [UIColor randomColor];
    self.timeLabel.text = @"周日周六";
    self.actLabel.text = @"花了股么鸟";
    self.addressLabel.text = @"所需积分：90";
    self.actNumberLabel.text = @"【10张】";
    self.statusLabel.text = @"企";
    for (int i = 0; i < 4; i ++) {
        UIImageView *imageView = [UIImageView new];
        imageView.contentMode = UIViewContentModeCenter;
        imageView.image = [UIImage imageNamed:@"icon_star"];
        imageView.frame = CGRectMake(152 * [UIScreen zj_screenWScale] + 28 * [UIScreen zj_screenWScale] * i, 50 * [UIScreen zj_screenHScale], 23 * [UIScreen zj_screenWScale], 23 * [UIScreen zj_screenHScale]);
        [self addSubview:imageView];
    }
//    [self.actImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASEIMAGEURL,model.COVER_JSON[0][@"file_path"]]] placeholderImage:PlaceholderImage];
//
//    if (model.ADDRESS.length == 0) {
//        self.addressLabel.text = @"暂无";
//    }else{
//        self.addressLabel.text = model.ADDRESS;
//    }
//    if (model.START_TIME.length == 0) {
//        self.timeLabel.text = @"待定";
//    }else{
//        self.timeLabel.text = model.START_TIME;
//    }
//
//    if (model.ENROLL_NUM.length == 0 || [model.ENROLL_NUM isEqualToString:@"0"]) {
//        self.actNumberLabel.hidden = YES;
//    }else{
//        self.actNumberLabel.text = [NSString stringWithFormat:@"已报名%@人",model.ENROLL_NUM];
//    }
//
//    if (self.index == 0) {
//        self.statusLabel.hidden = YES;
//    }else{
//        self.statusLabel.text = model.IS_START;
//    }
//
//
//
//    /**  设置行距  */
//    NSMutableAttributedString *text2 = [[NSMutableAttributedString alloc] initWithString:model.DESCRIPTION];
//
//    NSMutableParagraphStyle *style2 = [[NSMutableParagraphStyle alloc] init];
//    style2.headIndent = 0;
//    style2.lineSpacing = 6 * [UIScreen zj_screenHScale];
//    [text2 addAttribute:NSParagraphStyleAttributeName value:style2 range:NSMakeRange(0, text2.length)];
//
//    self.actLabel.attributedText = text2;
//    if (model.HEIGHT < 60 * [UIScreen zj_screenHScale]) {
//        self.actLabel.sd_layout.heightIs(model.HEIGHT);
//    }

}




#pragma mark - getter

- (UIImageView *)actImageView{
    if (!_actImageView) {
        _actImageView = [UIImageView new];
    }
    return _actImageView;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _timeLabel;
}

- (UILabel *)actNumberLabel{
    if (!_actNumberLabel) {
        _actNumberLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentRight;
            label.textColor = [UIColor themeColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _actNumberLabel;
}


- (UILabel *)statusLabel{
    if (!_statusLabel) {
        _statusLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentCenter;
            label.backgroundColor = [UIColor themeColor];
            label.textColor = [UIColor whiteColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            [label setRadius:6 byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight];
            label.layer.masksToBounds = YES;
            label;
        });
    }
    return _statusLabel;
}

- (UILabel *)addressLabel{
    if (!_addressLabel) {
        _addressLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _addressLabel;
}

- (UILabel *)actLabel{
    if (!_actLabel) {
        _actLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _actLabel;
}
@end
